<template>
  <el-menu
    default-active="2"
    class="el-menu-vertical-demo"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b"
    :collapse="isCollapse"
  >
    <h3 v-show="isCollapse">法律</h3>
    <h3 v-show="!isCollapse">法务课堂学习平台</h3>
    <el-submenu
      :index="item.label"
      v-for="(item, index) in asideMenu"
      :key="index"
    >
      <template slot="title">
        <i :class="'el-icon-' + item.icon"></i>
        <span slot="title">{{ item.label }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item
          :index="subItem.path"
          v-for="(subItem, subIndex) in item.children"
          :key="subIndex"
          @click="clickMenu(subItem)"
        >
          <i :class="'el-icon-' + subItem.icon"></i>
          <span slot="title">{{ subItem.label }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false,
      asideMenu: [
        {
          label: "法条资源",
          icon: "folder",
          children: [
            {
              path: "/resource",
              name: "Resource",
              label: "法条资源",
              icon: "setting",
            },
          ],
        },
        {
          label: "案例学习",
          icon: "notebook-2",
          children: [
            {
              path: "/learn_list",
              name: "LearnList",
              label: "案例学习",
              icon: "notebook-2",
            },
          ],
        },
        {
          label: "案情分析",
          icon: "search",
          children: [
            {
              path: "/analyse",
              name: "Analyse",
              label: "案情分析",
              icon: "search",
            },
          ],
        },
        {
          label: "焦点讨论",
          icon: "chat-line-round",
          children: [
            {
              path: "/discuss",
              name: "Discuss",
              label: "焦点讨论",
              icon: "chat-line-round",
            },
          ],
        },
        {
          label: "个人中心",
          icon: "user",
          children: [
            {
              path: "/user",
              name: "User",
              label: "个人中心",
              icon: "user",
            },
          ],
        },
        {
          label: "工具",
          icon: "s-tools",
          children: [
            {
              path: "/tools",
              name: "Tools",
              label: "工具",
              icon: "s-tools",
            },
          ],
        },
      ],
    };
  },
  methods: {
    clickMenu(item) {
      // console.log(item.path)
      // console.log(this.$route)
      if (item.path != this.$route.path) {
        this.$router.push({ name: item.name }); //路由跳转
        console.log("success");
      }

      // console.log('点击成功')
    },
  },
  computed: {
    //     isCollapse() {
    //   return this.$store.state.isCollapse
    // },
  },
};
</script>

 <style lang="scss" scoped>
.el-menu {
  height: 100%;
  border: none;
  h3 {
    color: #ffffff;
    text-align: center;
    line-height: 48px;
  }
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>
    
  
    
  

 

 



